<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title></title>
</head>

<body>
邮箱：<input type="text" name="email" id="email" onblur="checkinput()">
<span id="emailbox"></span>
<script type="text/javascript">
    function checkinput(){
        var email=document.getElementById("email").value;//获取邮箱文本框的值
        var checkemail=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;//定义正则表达式
        if(checkemail.test(email)){//用正则表达式进行判断
            emailbox.innerHTML="邮箱符合要求";
        }else{
            emailbox.innerHTML="请使用正确的邮箱格式";
        }
    }
</script>
</body>
</html>
